﻿using Hidistro.Entities.Sales;
using Hidistro.UI.Common.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;


namespace Hidistro.UI.SaleSystem.Tags
{
    public struct PromotionShopInfo
    {
        public string Name { get; set; }
        public decimal Condition { get; set; }
        public decimal DiscountValue { get; set; }
        public decimal Total { get; set; }
        public List<ShoppingCartItemInfo> ShopInfo;
    }
    public class wnxd_ShoppingCart_Promotions : AscxTemplatedWebControl
    {
        Repeater PtList;
        protected override void AttachChildControls()
        {
            this.PtList = (Repeater)this.FindControl("PtList");
            this.PtList.ItemDataBound += PList_ItemDataBound;
        }

        void PList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater Plist = (Repeater)e.Item.FindControl("PList");
                PromotionShopInfo psi = (PromotionShopInfo)e.Item.DataItem;
                Plist.DataSource = psi.ShopInfo;
                Plist.DataBind();
            }
        }
        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "/ascx/tags/Common_ShoppingCart/wnxd_ShoppingCart_Promotions.ascx";
            }
            base.OnInit(e);
        }
        public object DataSource
        {
            get
            {
                return this.PtList.DataSource;
            }
            set
            {
                this.EnsureChildControls();
                this.PtList.DataSource = value;
            }
        }
        public override void DataBind()
        {
            this.EnsureChildControls();
            if (this.PtList.DataSource != null)
            {
                this.PtList.DataBind();
            }
        }
        public override string ID
        {
            get
            {
                return base.ID;
            }
            set
            {
                base.ID = value;
            }
        }
    }
}
